package com.hmy.finance.service.receipt.dto;

import com.hmy.ccp.common.dto.BaseDto;
import com.hmy.finance.api.bo.core.request.enums.ReceiptOffsetBillStatusEnum;
import com.hmy.finance.api.bo.core.request.enums.ReceiptedTypeEnum;
import com.hmy.finance.dal.po.receipt.json.AccountInfoJson;
import com.hmy.finance.dal.po.receipt.json.CustomerContactorJson;
import com.hmy.finance.dal.po.receipt.json.CustomerInfoJson;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;

import lombok.Data;
import lombok.EqualsAndHashCode;


@Data
@EqualsAndHashCode(callSuper = true)
public class ReceiptOffsetBillProcessVariableDto extends BaseDto {
    /**
     * 主键ID
     */
    private Long receiptOffsetBillId;

    /**
     * 单据编号
     */
    private String receiptOffsetBillNo;

    /**
     * 当前流程任务的id
     */
    private String processCurrentTaskId;

    /**
     * 客户ID
     */
    private Long customerId;

    /**
     * 客户ID
     */
    private String customerName;

    /**
     * 客户扩展信息
     */
    private CustomerInfoJson customerExtensionInfo;

    /**
     * 分摊联系人信息
     */
    private List<CustomerContactorJson> customerContactorExtensionInfos;

    /**
     * 关联凭证信息ID
     */
    private Long voucherId;

    /**
     * 客户以及联系人账户信息，包含当前余额信息以及分摊信息
     */
    private AccountInfoJson accountExtensionInfos;

    /**
     * 是否分摊，0-否；1-是
     */
    private Integer isApportion;

    /**
     * 备注信息
     */
    private String remarks;

    /**
     * 单据状态
     */
    private Integer billStatus;

    /**
     * 单据状态描述
     */
    private String billStatusAlias;

    /**
     * 前端展示
     */
    private String billStatusDisPlayAlias;

    /**
     * 收款日期
     */
    private LocalDateTime receiptedTime;

    /**
     * 收款金额
     */
    private BigDecimal receiptedAmount;

    /**
     * 收款类型
     */
    private Integer receiptedType;

    /**
     * 收款类型描述
     */
    private String receiptedTypeAlias;

    /**
     * 收款类型描述-前端展示
     */
    private String receiptedTypeDisPlayAlias;

    /**
     * 驳回意见
     */
    private String rejectedOpinion;

    /**
     * 销售经理ID
     */
    private Long saleManagerId;

    /**
     * 销售经理姓名
     */
    private String saleManagerName;

    /**
     * 销售经理所属部门ID
     */
    private Long saleManagerDeptId;

    /**
     * 创建人ID
     */
    private Long creatorId;

    /**
     * 创建人姓名
     */
    private String creatorName;

    /**
     * 更新人ID
     */
    private Long updaterId;

    /**
     * 更新人姓名
     */
    private String updaterName;

    /**
     * 跳过标识
     */
    private Integer rejectCount = 0;

    /**
     * 业务状态
     */
    private Integer businessStatus;

    /**
     * 业务状态描述
     */
    private String businessStatusAlias;

    /**
     * 流程实例Id
     */
    private String processInstanceId;

    public void buildReceiptOffsetBillStatus(ReceiptOffsetBillStatusEnum receiptOffsetBillStatusEnum) {
        this.setBillStatus(receiptOffsetBillStatusEnum.getStatusCode());
        this.setBillStatusAlias(receiptOffsetBillStatusEnum.getStatusDesc());
        this.setBillStatusDisPlayAlias(receiptOffsetBillStatusEnum.getDisplayDesc());
        this.setBusinessStatus(receiptOffsetBillStatusEnum.getStatusCode());
        this.setBusinessStatusAlias(receiptOffsetBillStatusEnum.getDisplayDesc());
        this.setReceiptedTypeAlias(Objects.requireNonNull(ReceiptedTypeEnum.getEnumByType(receiptedType)).getStatusDesc());
        this.setReceiptedTypeDisPlayAlias(ReceiptedTypeEnum.getDisPlayDescByType(receiptedType));
    }
}